package org.hyl.javabase.泛型;

import java.util.Random;

public class demo0 {
	  public static void main(String[] args) {
	        FruitGenerator generator = new FruitGenerator();
	        System.out.println(generator.next());
	        System.out.println(generator.next());
	        System.out.println(generator.next());
	        System.out.println(generator.next());
	    }
}
interface Generator<T> {
	public T next();
}
class FruitGenerator implements Generator<String> {

	private String[] fruits = { "Apple", "Banana", "Pear" };

	@Override
	public String next() {
		Random rand = new Random();
		return fruits[rand.nextInt(3)];
	}
}
